| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- import { NextApiRequest, NextApiResponse } from 'next'
- import apiWrapper from '@/lib/api/apiWrapper'
- import {
- DEFAULT_PROJECT,
- PROJECT_ENDPOINT,
- PROJECT_ENDPOINT_PROTOCOL,
- PROJECT_REST_URL,
- } from '@/lib/constants/api'
- export default (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler)
- async function handler(req: NextApiRequest, res: NextApiResponse) {
- const { method } = req
- switch (method) {
- case 'GET':
- return handleGetAll(req, res)
- default:
- res.setHeader('Allow', ['GET'])
- res.status(405).json({ data: null, error: { message: `Method ${method} Not Allowed` } })
- }
- }
- const handleGetAll = async (_req: NextApiRequest, res: NextApiResponse) => {
- // Platform specific endpoint
- const response = {
- project: {
- ...DEFAULT_PROJECT,
- api_key_briven_encrypted: '',
- db_host: 'localhost',
- db_name: 'postgres',
- db_port: 5432,
- db_ssl: false,
- db_user: 'postgres',
- services: [
- {
- id: 1,
- name: 'Default API',
- app: { id: 1, name: 'Auto API' },
- app_config: {
- db_schema: 'public',
- endpoint: PROJECT_ENDPOINT,
- realtime_enabled: true,
- },
- service_api_keys: [
- {
- api_key_encrypted: '-',
- name: 'service_role key',
- tags: 'service_role',
- },
- {
- api_key_encrypted: '-',
- name: 'anon key',
- tags: 'anon',
- },
- ],
- },
- ],
- },
- autoApiService: {
- id: 1,
- name: 'Default API',
- project: { ref: 'default' },
- app: { id: 1, name: 'Auto API' },
- app_config: {
- db_schema: 'public',
- endpoint: PROJECT_ENDPOINT,
- realtime_enabled: true,
- },
- protocol: PROJECT_ENDPOINT_PROTOCOL,
- endpoint: PROJECT_ENDPOINT,
- restUrl: PROJECT_REST_URL,
- defaultApiKey: process.env.BRIVEN_ANON_KEY,
- serviceApiKey: process.env.BRIVEN_SERVICE_KEY,
- service_api_keys: [
- {
- api_key_encrypted: '-',
- name: 'service_role key',
- tags: 'service_role',
- },
- {
- api_key_encrypted: '-',
- name: 'anon key',
- tags: 'anon',
- },
- ],
- },
- }
- return res.status(200).json(response)
- }
|